#!/usr/bin/env python

import sys
sys.path.insert(0, "pybake")
import pybake3 as pybake
pkg_config = pybake.pkg_config

conf, opts, targs = pybake.parse_args()
rules = pybake.Rules()

baseproj = pybake.cxproject(
	defines=["_FILE_OFFSET_BITS=64", "_GNU_SOURCE"],
	cflags=["-std=gnu99", "-Wshadow", "-Werror-implicit-function-declaration"],
	cxxflags=["-std=gnu++0x"],
	cxflags=["-g", "-Wall", "-fdiagnostics-show-option", "-Werror=return-type", "-Wno-sign-compare", "-Wextra", "-Wno-missing-field-initializers"])

cpfs = baseproj.copy(name="cpfs", sourcedir="src/cpfs", kind="static")
cpfs.incdirs += ["include", "cxutil/include"]
cpfs.add_to(rules)

cxutil = cpfs.copy(name="cxutil", sourcedir="cxutil/src/cxutil")
cxutil.incdirs += ["cxutil/include/cxutil"]
cxutil.add_to(rules)

mkfs = cpfs.copy(name="mkfs.cpfs", sourcedir="src/mkfs.cpfs", libraries=["boost_program_options"], kind="console")
mkfs.objects += [cpfs._target, cxutil._target]
mkfs.add_to(rules)

mount = cpfs.copy(name="mount.cpfs", sourcedir="src/mount.cpfs", kind="console")
mount.cxflags += pybake.pkg_config(["--cflags"], ["fuse"])
mount.defines += ["FUSE_USE_VERSION=28"]
mount.objects += [cpfs._target, cxutil._target]
mount.linkopts += pkg_config(["--libs"], ["fuse"])
mount.libraries += ["stdc++"]
mount.add_to(rules)

systest = baseproj.copy(name="systest", sourcedir="src/systest", incdirs=["cxutil/include/cxutil"])
systest.add_to(rules)

#print rules
pybake.make(rules, opts, targs)
